//引入数据库
const { mysql } = require('../qcloud')

//kenx操作数据库
module.exports = async(ctx) => {
    //获取前端传递的data元素
    const { opinion, src, wechat, openid } = ctx.request.body
    try{
        await mysql('cauth_opinions').insert({
            opinion, src, wechat, openid
        })
        //将获取到的opinion信息传递给前端
        ctx.state.data = {
        code: 0,
        msg: "success"
        }
        console.log('成功');
    }catch(e) {
        ctx.state = {
            code: -1,
            data: {
                msg: '添加失败' + e.sqlMessage
            }
        }
        console.log('错误');
        
    }
}